package com.atguigu.eduSta.controller;


import com.atguigu.common.Result;
import com.atguigu.eduSta.service.StatisticsDailyService;
import io.swagger.annotations.ApiOperation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

/**
 * <p>
 * 网站统计日数据 前端控制器
 * </p>
 *
 * @author smday
 * @since 2020-08-03
 */
@RestController
@RequestMapping("/sta")
public class StatisticsDailyController {

    @Resource
    private StatisticsDailyService statisticsDailyService;

    @ApiOperation("统计某一天的注册人数")
    @PostMapping("/registerNum/{date}")
    @Transactional
    public Result registerCount(@PathVariable String date) {
        statisticsDailyService.registerCount(date);
        return Result.ok();
    }

    @ApiOperation("图表显示")
    @GetMapping("/data")
    public Result showData(@RequestParam("type") String type,
                           @RequestParam("begin") String begin,
                           @RequestParam("end") String end) {
        Map<String,Object> map = statisticsDailyService.getShowData(type,begin,end);
        return Result.ok().data(map);
    }

}

